<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单引用获取</title>
</head>
<body>
    <form action="" name="firstForm" id="firstForm"></form>
    <form action="" name="secondForm"></form>
</body>
<script>
    //获取对<form>元素的引用-方法一
    let firstFormById = document.getElementById('firstForm');
    let firstFormByIndex = document.forms[0];
    let firstFormByName = document.forms['firstForm'];
    console.log(firstFormById,firstFormByIndex,firstFormByName);//<form action="" name="firstForm" id="firstForm"></form>
    console.log(firstFormById === firstFormByIndex);//true
    console.log(firstFormByIndex === firstFormByName);//true
</script>
</html>